// render.cpp
//

#include "PursuitDrift.h"

PRGameMenu PD_Menu;

void PDRenderGame(float deltatime)
{
	// Bei einem NULL Device abbrechen bevor's Kracht
	if (PR_D3D_Device == NULL)
		return;

	PR_D3D_Device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

	PR_D3D_Device->BeginScene();

	PRSMRender(deltatime);

#ifdef _DEBUG
	PRDrawText("Debug", 5, 5, D3DCOLOR_XRGB(255, 255, 255));
	PDDrawFrameRate(deltatime);
#endif
#ifdef DEMO
	PRDrawText("Demo", 5, 25, D3DCOLOR_XRGB(255, 255, 255));
#endif
	
	PR_DxSprite->Flush();
	PR_D3D_Device->EndScene();
}

float ftime = 0;
int frames = 0;
int fps = 0;

void PDDrawFrameRate(float deltatime)
{
	char text[256];

	ftime += deltatime;
	frames++;

	if (ftime > 1)
	{
		fps = frames;
		ftime = 0.0f;
		frames = 0;
	}

	sprintf(text, "FPS: %d", fps);
	PRDrawText(text, 60, 5, D3DCOLOR_XRGB(255, 255, 255));
}